<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>scripting flash</title>
<style>
    #re1, #re2, #re3, #re4 {
        padding: 10px;
        border: 1px solid green;
    }
</style>
</head>
<body>
<h1>flash引入方式 - 1</h1>
<p>Adobe官方 示例 (按友善界面原则不推荐使用)</p>
<h2>地址：</h2>
<p id="re1">

</p>

<h1>flash引入方式 - 2</h1>
<p>SWFObject 静态官方式 示例 （强势推荐）（若是移动平台，则不推荐）</p>
<h2>地址：</h2>
<p id="re2">

</p>

<h1>flash引入方式 - 3</h1>
<p>最简方式：ie需要加载两次</p>
<h2>地址：</h2>
<p id="re3">

</p>


<h1>flash引入方式 - 4</h1>
<p>单独使用 embed(不建议使用)</p>
<h2>地址：</h2>
<p id="re4">

</p>

<script src="../../base/javascript/ks-core.js" charset="utf-8"></script>
<script>


    var flashGen = [
        '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
                + ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"'
                + ' width="400" height="300" id="movie1">'
                + ' <param name="movie" value="7.swf"/>'
                + ' <embed src="7.swf" quality="high" width="400" height="300" name="movie"'
                + '  type="application/x-shockwave-flash"'
                + '  width="400" height="300"'
                + '  pluginspage="http://www.macromedia.com/go/getflashplayer"/>'
                + '</object>',
        '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
                + ' width="400" height="300" id="movie2">'
                + ' <param name="movie" value="7.swf"/>'
                + '<!--[if !IE]>-->'
                + '<object type="application/x-shockwave-flash"'
                + '     data="7.swf"'
                + '      width="400" height="300">'
                + '  <!--<![endif]-->'
                + '  <a href="http://www.adobe.com/go/getflashplayer">'
                + '      <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"'
                + '          alt="Get Adobe Flash player"/>'
                + '</a>'
                + ' <!--[if !IE]>-->'
                + '</object>'
                + ' <!--<![endif]-->'
                + '</object>',
        '<object type="application/x-shockwave-flash"'
                + '  data="7.swf"'
                + '   width="400" height="300"'
                + '  id="movie3">'
                + '<param name="movie" value="7.swf"/>'
                + ' <a href="go/getflashplayer">'
                + '    <img src="get_flash_player.gif" alt="Get Adobe Flash player"/>'
                + ' </a>'
                + '</object>',

        '<embed'
                + '       id="movie4"'
                + '       src="7.swf"'
                + '     quality="high" width="400" height="300" name="movie"'
                + '   type="application/x-shockwave-flash"'
                + ' pluginspage="http://www.macromedia.com/go/getflashplayer"/>'
    ];
    var S = KISSY,Node = S.Node,DOM = S.DOM;
    Node.prototype.name = function() {
        return this[0].nodeName.toLowerCase();
    };
    Node.prototype.getByTag = function(tag) {
        var el = this[0];
        var res = el.getElementsByTagName(tag);
        if (res.length == 0) {
            //ie quirks if not inserted into document
            res = el.getElementsByTagName(tag.toUpperCase());
        }
        //alert(el.id + " : " + tag + " : " + res.length);
        return S.makeArray(res);
    };
    function isUrl(url) {
        return /^http:/i.test(url);
    }

    function getFlashUrl(elem) {
        if (elem.name() == "object") {
            if (isUrl(elem.attr("data"))) {
                return elem.attr("data");
            }
            var params = elem.getByTag("param"),objects = elem.getByTag("object"),
                    embeds = elem.getByTag("embed"),param,object,embed;
            for (var i = 0; i < params.length; i++) {
                param = params[i];
                if (DOM.attr(param, "name") == "movie")
                    return DOM.attr(param, "value");
            }
            for (i = 0; i < objects.length; i++) {
                object = objects[i];
                if (isUrl(object.attr("data"))) {
                    return object.attr("data");
                }
            }
            for (i = 0; i < embeds.length; i++) {
                embed = embeds[i];
                return embed.attr("src");
            }

        } else if (elem.name() == "embed") {
            return elem.attr("src");
        }
        return "";
    }


    for (var i = 1; i < 5; i++) {
        var m = new Node(flashGen[i - 1]);
        //alert(m[0].outerHTML);
        var url = getFlashUrl(m);
        S.one("#re" + i).html(url);
        m.insertBefore(S.one("#re" + i));
    }
</script>
</body>
</html>